package com.luntsevich.topten;

import java.util.Arrays;
import junit.framework.TestCase;

public class TopTenTest extends TestCase {
	public void testTopThreeInts() {
		Integer one = new Integer(1);
		Integer two = new Integer(2);
		Integer three = new Integer(3);
		Integer four = new Integer(4);
		Integer five = new Integer(5);
		Integer six = new Integer(6);

		assertEquals(
				Arrays.asList(new Integer[] { one, two, three }),
				TopTen.getTopN(
						3,
						Arrays.asList(new Integer[] { one, two, three, four,
								five, six })));
	}

	public void testTopTwoStrings() {
		assertEquals(
				Arrays.asList(new String[] { "a", "b" }),
				TopTen.getTopN(2,
						Arrays.asList(new String[] { "a", "b", "c", "d" })));
	}

	public void testTopJoke() {
		Joke chicken = new Joke("Why did the chicken cross the road?");
		Joke grapenuts = new Joke("What is up with grape nuts?");
		Joke sausage = new Joke("Ack!  A talking sausage!");
		Joke bar = new Joke("Two men walk into a bar.  The third ducks.");
		assertEquals(
				Arrays.asList(new Joke[] { chicken }),
				TopTen.getTopN(
						1,
						Arrays.asList(new Joke[] { chicken, grapenuts, sausage,
								bar })));
	}
}
